package cn.biplam.common.file.importfile.sheet;

import org.apache.poi.hssf.usermodel.HSSFSheet;

import cn.biplam.common.file.ExcelFile;
import cn.biplam.common.wrapper.ErrorMessage;

public class SingleSheet {
	
	/** 行信息 String["表英文名","表中文名","字段名","字段中文名","字段说明"]*/
	private int rowNum;
	/** 计数器*/
	private int count;
	HSSFSheet sheet;
	
	public SingleSheet(HSSFSheet sheet) throws ErrorMessage{
		this.sheet = sheet;
		rowNum = ExcelFile.getRowSize(sheet);
		count = -1;
	}
	
	/**
	 * 是否有下一行
	 * @return
	 */
	public boolean haveNext(){
		if(count<rowNum-1){
			return true;
		}
		return false;
	}
	
	/**
	 * 指针下移
	 */
	public void next(){
		count++;
	}
	
	/**
	 * 取表名
	 * @return
	 * @throws ErrorMessage
	 */
	public String getTableName() throws ErrorMessage{
		return ExcelFile.getCellContent(sheet, count, 0);
	}
	
	/**
	 * 取表中文名
	 * @return
	 * @throws ErrorMessage
	 */
	public String getTableCnName() throws ErrorMessage{
		return ExcelFile.getCellContent(sheet, count, 1);
	}
	
	/**
	 * 取表中文名
	 * @return
	 * @throws ErrorMessage
	 */
	public String getTableComments() throws ErrorMessage{
		return null;
	}
	
	/**
	 * 取表名
	 * @return
	 * @throws ErrorMessage
	 */
	public String getColumnName() throws ErrorMessage{
		return ExcelFile.getCellContent(sheet, count, 2);
	}
	
	/**
	 * 取表中文名
	 * @return
	 * @throws ErrorMessage
	 */
	public String getColumnCnName() throws ErrorMessage{
		return ExcelFile.getCellContent(sheet, count, 3);
	}
	
	/**
	 * 取表中说明
	 * @return
	 * @throws ErrorMessage
	 */
	public String getColumnComments() throws ErrorMessage{
		return ExcelFile.getCellContent(sheet, count, 4);
	}
}
